import fetch from '@/utils/fetch'
import {getUserId} from '@/utils/token'

export function apiAddAcceptOrder(acceptOrderDto) {
  acceptOrderDto.userId = getUserId()
  return fetch({
    url: '/api/v1/acceptOrder',
    method: 'POST',
    data: acceptOrderDto
  })
}

export function apiGetAcceptOrderList(listQuery) {
  return fetch({
    url: '/api/v1/acceptOrder/list',
    method: 'GET',
    params: listQuery
  })
}

export function apiGetAcceptOrder(id) {
  return fetch({
    url: '/api/v1/acceptOrder',
    method: 'GET',
    params: {id: id}
  })
}

export function apiPostAcceptOrder(id) {
  return fetch({
    url: '/api/v1/acceptOrder/factory',
    method: 'POST',
    data: {id: id}
  })
}

export function apiUpdAcceptOrder(dto) {
  return fetch({
    url: '/api/v1/acceptOrder',
    method: 'put',
    data: dto
  })
}

export function apiDelAcceptOrder(id) {
  return fetch({
    url: '/api/v1/acceptOrder',
    method: 'delete',
    params: {
      id: id
    }
  })
}

export function apiGetReturnList(listQuery) {
  return fetch({
    url: '/api/v1/acceptOrder/returnList',
    method: 'GET',
    params: listQuery
  })
}

export function apiGetYstsnList(listQuery) {
  return fetch({
    url: '/api/v1/maintenanceRecord/sn',
    method: 'post',
    data: listQuery
  })
}

export function apiExport(listQuery) {
  return fetch({
    url: '/api/v1/acceptOrder/export',
    method: 'post',
    data: listQuery,
    responseType: 'arraybuffer'
  })
}

export function apiGetWarrantyDeviceInfo(listQuery) {
  return fetch({
    url: '/api/v1/acceptOrder/warranty',
    method: 'GET',
    params: listQuery
  })
}

export function apiGetDeviceCurrentStatus(ystsn) {
  return fetch({
    url: '/api/v1/acceptOrder/status',
    method: 'GET',
    params: { ystsn: ystsn }
  })
}
